/**
 *
    算法描述：累加求最值问题，较为基础
    解决所需数据结构+算法：
**/
#include<iostream>
#include<cstring>
using namespace std;

int main() {
    int n, m, a[3010], b[3010], mx = 1000000000;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    cin >> n >> m;

    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=m; i<=n; i++) {
        for(int j=i-m+1; j<=i; j++)
            b[i] += a[j];
        if(b[i] < mx)   mx = b[i];
    }
    cout << mx << endl;

    return 0;
}